<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<input type="text" placeholder="请输入一个整数"><input type="text" placeholder="请输入一个整数">
<button id="btn">计算</button>
<input type="text" placeholder="计算到的最大公约数"><input type="text" placeholder="计算到的最小公倍数">
<script>
var inputs = document.getElementsByTagName("input");
var btn = document.getElementById("btn");
btn.onclick = function (){
    var num1 = +inputs[0].value;
    var num2 = +inputs[1].value;

    inputs[2].value = largestConvention(num1, num2)
    inputs[3].value = leastCommonMultiple(num1, num2)
}
function largestConvention(num1, num2){
    var min = num1 < num2 ? num1 : num2;
    
    for(var i = min; i >= 1; i--){
        if(num1 % i == 0 && num2 % i == 0){
            return i;
        }
    }
    
}
function leastCommonMultiple(num1, num2){
    var max = num1 > num2 ? num1 : num2;
    for(var i = max; ; i++){
        if(i % num1 == 0 && i % num2 == 0){
            return i;
        }
    }
}
//可以计算指定区间的随机整数 [m, n] 的函数


</script>
</body>

</html>